from dataclasses import dataclass, asdict
from typing import List


@dataclass
class SpecValueItem(object):
    """
    规格值项
    """
    spec_value: str
    spec_simple: str
    list_price: str
    sale_price: str
    inventory: str


@dataclass
class SpecDetail(object):
    """
    规格详情
    """
    spec_name: str
    spec_value_items: List[SpecValueItem]


@dataclass
class GoodsDetail(object):
    """
    商品名称
    """
    applet_id:str
    shop_id:str
    goods_name: str
    goods_simple: str
    goods_code: str
    making_code: str
    goods_category: str
    goods_img_url: str
    basic_price: str
    takeout_price: str
    selling_point: str
    spec_record: List[SpecDetail]
    goods_tag_list: List[str]
    allergen_list: List[str]
    good_status: bool
    is_recommend: bool
    is_required: bool
    is_only_pos: bool


if __name__ == '__main__':
    goods = GoodsDetail(
        goods_name="示例商品",
        goods_simple="示例",
        goods_code="123456",
        making_code="ABC123",
        goods_category="饮料",
        goods_img_url="http://example.com/image.jpg",
        basic_price="10.00",
        takeout_price="12.00",
        selling_point="好喝",
        spec_record=[SpecDetail("尺寸", [SpecValueItem("大", "L", "12.00", "10.00", "100")])],
        goods_tag_list=["热销", "新品"],
        allergen_list=["花生","乳制品"],
        good_status="上架",
        is_recommend=True,
        is_required=False,
        is_only_pos=False
    )

    print(asdict(goods))
